<template>
    <div class="planList-index yuan-container">
        <div class="overview-panel" v-if="planSimulationObj['包装计划']">
            <div class="overview-titlebox">
                <span class="overview-title yuan-title">预计分解计划</span>
                <span>
                    当前成品计划包装量：<span
                        class="c-primary font-bignum">{{Number(formData.bigProNum)+Number(formData.smallProNum) | toDecimalNoZero}}</span>袋；
                    配方颗粒(颗粒)投入量：<span
                        class="c-primary font-bignum">{{planSimulationObj['包装计划'].xuqiu | toDecimalNoZero}}</span>kg；
                    可分解
                </span>
            </div>
            <div>
                <div class="overview-list" v-for="item in planSimulation" :key="item.planName">
                    {{item.planName}}：
                    需求量：
                    <NumberAnimation class="c-primary font-bignum" :num="item.xuqiu" />kg，
                    计划生产量：
                    <NumberAnimation class="c-warning font-bignum" :num="item.inNum" />kg，
                    现有库存量：
                    <NumberAnimation class="c-success font-bignum" :num="item.surplus" />kg，

                </div>
            </div>

        </div>
        <a-card v-if="planSimulationObj['包装计划']">
            <a-tabs type="card" :default-active-key="pageType" @change="tabChange">
                <a-tab-pane v-for="item in typeArr" :key="item.val" :tab="item.title"></a-tab-pane>
            </a-tabs>

            <!-- 包装计划 -->
            <template v-if="pageType==='包装计划'">
                <div class="planList-top">
                    <span
                        class="planList-title">{{planSimulationObj['包装计划'].planName}}({{planSimulationObj['包装计划'].planSerial}})</span>
                    <span style="margin-left:20px">计划状态：<span class="c-primary">待生产</span> </span>
                    <!-- <a-button type="primary" style="float:right;margin-left:10px">销售天数优先</a-button>
                    <a-button type="primary" style="float:right">批次优先</a-button> -->
                </div>

                <div class="filter-panel">
                    <div class="filter-list">
                        <span class="filter-tips ">需求量：
                            <span class="font-bignum c-primary">{{planSimulationObj['包装计划'].xuqiu}}</span>
                            kg</span>
                    </div>
                    <div class="filter-list">
                        <span class="filter-tips">现有库存量：
                            <span class="font-bignum c-success">{{planSimulationObj['包装计划'].surplus}}</span>
                            kg</span>
                    </div>
                </div>
                <a-form-model layout="inline" class="yuan-form" :label-col="{ style: { width: '150px' } }"
                    :wrapper-col="{ style: { width: 'calc(100% - 160px)' } }">
                    <div class="form-panel" style="padding:5px 0">
                        <div class="form-panel-box">
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="成品批号">
                                <span class="mast-ico"></span>
                                <a-input class="yuan-form-input" placeholder="请输入批号"
                                    v-model="planSimulationObj['包装计划'].batch"></a-input>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="计划生产量">
                                <span class="yuan-form-show">{{planSimulationObj['包装计划'].inNum | toDecimalNoZero}}kg</span>

                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="预计完成时间">
                                <span class="mast-ico"></span>
                                <a-date-picker class="yuan-form-input" placeholder="预计完成时间"
                                    v-model="planSimulationObj['包装计划'].finishTime" valueFormat="YYYY-MM-DD" />
                            </a-form-model-item>
                        </div>
                    </div>
                </a-form-model>

                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="bzPageList" :columns="packageColumns"
                        :pagination="false" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量" v-model="bzPageList[index].number" />
                        </template>
                    </a-table>
                </div>
            </template>

            <!-- 制剂计划 -->
            <template v-else-if="pageType==='制剂计划'">
                <div class="planList-top">
                    <span
                        class="planList-title">{{planSimulationObj['制剂计划'].planName}}({{planSimulationObj['制剂计划'].planSerial}})</span>
                    <span style="margin-left:20px">计划状态：<span class="c-primary">待生产</span> </span>
                </div>
                <div class="filter-panel">
                    <div class="filter-list">
                        <span class="filter-tips ">需求量：
                            <span class="font-bignum c-primary">{{planSimulationObj['制剂计划'].xuqiu}}</span>
                            kg</span>
                    </div>
                    <div class="filter-list">
                        <span class="filter-tips">现有库存量：
                            <span class="font-bignum c-success">{{planSimulationObj['制剂计划'].surplus}}</span>
                            kg</span>
                    </div>
                </div>
                <a-form-model layout="inline" class="yuan-form" :label-col="{ style: { width: '150px' } }"
                    :wrapper-col="{ style: { width: 'calc(100% - 160px)' } }">
                    <div class="form-panel" style="padding:5px 0">
                        <div class="form-panel-box">
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="颗粒批号">
                                <span class="mast-ico"></span>
                                <a-input class="yuan-form-input" v-model="planSimulationObj['制剂计划'].batch"
                                    placeholder="请输入批号"></a-input>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="计划生产量">
                                <span class="yuan-form-show">{{planSimulationObj['制剂计划'].inNum | toDecimalNoZero}}kg</span>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="预计完成时间">
                                <span class="mast-ico"></span>
                                <a-date-picker class="yuan-form-input" v-model="planSimulationObj['制剂计划'].finishTime"
                                    placeholder="预计完成时间" valueFormat="YYYY-MM-DD" />
                            </a-form-model-item>
                        </div>
                    </div>
                </a-form-model>

                <div class="planList-top">
                    <span class="yuan-title">提取物</span>
                </div>
                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="zjPageList" :columns="preparColumns"
                        :pagination="false" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量" v-model="zjPageList[index].number" />
                        </template>
                    </a-table>
                </div>
                <div class="planList-top" style="margin-top:20px">
                    <span class="yuan-title">辅料</span>
                </div>
                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="accZjPageList" :columns="accessColumns"
                        :accZjpagination="false" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量"
                                v-model="accZjPageList[index].number" />
                        </template>
                    </a-table>
                </div>
            </template>
            <!-- 提取计划 -->
            <template v-else-if="pageType==='提取计划'">
                <div class="planList-top">
                    <span class="planList-title">提取计划({{planSimulationObj['提取计划'].planSerial}})</span>
                    <span style="margin-left:20px">计划状态：<span class="c-primary">待生产</span> </span>
                    <!-- <a-button type="primary" style="float:right;margin-left:10px">销售天数优先</a-button>
                    <a-button type="primary" style="float:right">批次优先</a-button> -->
                </div>
                <div class="filter-panel">
                    <div class="filter-list">
                        <span class="filter-tips ">需求量：
                            <span class="font-bignum c-primary">{{planSimulationObj['提取计划'].xuqiu}}</span>
                            kg</span>
                    </div>
                    <div class="filter-list">
                        <span class="filter-tips">现有库存量：
                            <span class="font-bignum c-success">{{planSimulationObj['提取计划'].surplus}}</span>
                            kg</span>
                    </div>
                </div>
                <a-form-model layout="inline" class="yuan-form" :label-col="{ style: { width: '150px' } }"
                    :wrapper-col="{ style: { width: 'calc(100% - 160px)' } }">
                    <div class="form-panel" style="padding:5px 0">
                        <div class="form-panel-box">
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="提取物批号">
                                <span class="mast-ico"></span>
                                <a-input class="yuan-form-input" v-model="planSimulationObj['提取计划'].batch"
                                    placeholder="请输入批号"></a-input>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="计划生产量">
                                <span class="yuan-form-show">{{planSimulationObj['提取计划'].inNum | toDecimalNoZero}}kg</span>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="预计完成时间">
                                <span class="mast-ico"></span>
                                <a-date-picker class="yuan-form-input" v-model="planSimulationObj['提取计划'].finishTime"
                                    placeholder="预计完成时间" valueFormat="YYYY-MM-DD" />
                            </a-form-model-item>
                        </div>
                    </div>
                </a-form-model>
                <div class="planList-top">
                    <span class="yuan-title">提取饮片</span>
                </div>
                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="tqPageList" :columns="extractColumns"
                        :pagination="false" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-select style="width:100px" v-model="tqPageList[index].number" placeholder="请选择">
                                <a-select-option value="200">200</a-select-option>
                                <a-select-option value="400">400</a-select-option>
                                <a-select-option value="600">600</a-select-option>
                            </a-select>
                        </template>
                        <template slot="count" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量" v-model="tqPageList[index].count" />
                        </template>
                    </a-table>
                </div>
                <div class="planList-top" style="margin-top:20px">
                    <span class="yuan-title">辅料</span>
                </div>
                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="accTqPageList" :columns="accessColumns"
                        :accTqpagination="false" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量"
                                v-model="accTqPageList[index].number" />
                        </template>
                    </a-table>
                </div>
            </template>
            <!-- 饮片计划 -->
            <template v-else-if="pageType==='饮片计划'">
                <div class="planList-top">
                    <span class="planList-title">饮片计划({{planSimulationObj['饮片计划'].planSerial}})</span>
                    <span style="margin-left:20px">计划状态：<span class="c-primary">待生产</span> </span>
                    <!-- <a-button type="primary" style="float:right;margin-left:10px">销售天数优先</a-button>
                    <a-button type="primary" style="float:right">批次优先</a-button> -->
                </div>
                <div class="filter-panel">
                    <div class="filter-list">
                        <span class="filter-tips ">需求量：
                            <span class="font-bignum c-primary">{{planSimulationObj['饮片计划'].xuqiu}}</span>
                            kg</span>
                    </div>
                    <div class="filter-list">
                        <span class="filter-tips">现有库存量：
                            <span class="font-bignum c-success">{{planSimulationObj['饮片计划'].surplus}}</span>
                            kg</span>
                    </div>
                </div>
                <a-form-model layout="inline" class="yuan-form" :label-col="{ style: { width: '150px' } }"
                    :wrapper-col="{ style: { width: 'calc(100% - 160px)' } }">
                    <div class="form-panel" style="padding:5px 0">
                        <div class="form-panel-box">
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="提取饮片批号">
                                <span class="mast-ico"></span>
                                <a-input class="yuan-form-input" v-model="planSimulationObj['饮片计划'].batch"
                                    placeholder="请输入批号"></a-input>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="计划生产量">
                                <span class="yuan-form-show">{{planSimulationObj['饮片计划'].inNum | toDecimalNoZero}}kg</span>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="前处理工艺流程">
                                <a-input class="yuan-form-input" v-model="planSimulationObj['饮片计划'].techProcess"
                                    placeholder="请输入工艺流程"></a-input>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="工艺注意事项">
                                <a-input class="yuan-form-input" v-model="planSimulationObj['饮片计划'].techNotice"
                                    placeholder="请输入注意事项"></a-input>
                            </a-form-model-item>
                            <a-form-model-item class="yuan-form-item yuan-form-col3" label="预计完成时间">
                                <span class="mast-ico"></span>
                                <a-date-picker valueFormat="YYYY-MM-DD" class="yuan-form-input"
                                    v-model="planSimulationObj['饮片计划'].finishTime" placeholder="预计完成时间" />
                            </a-form-model-item>
                        </div>
                    </div>
                </a-form-model>
                <div class="planList-top">
                    <span class="yuan-title">药材</span>
                    <!-- <span style="margin-left:20px">生产数量：500kg</span> -->
                </div>
                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="ypPageList" :columns="pieceColumns"
                        :pagination="false" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量" v-model="ypPageList[index].number" />
                        </template>
                    </a-table>
                </div>
                <div class="planList-top" style="margin-top:20px">
                    <span class="yuan-title">辅料</span>
                    <!-- <span style="margin-left:20px">生产数量：500kg</span> -->
                </div>
                <div class="table">
                    <a-table bordered :rowKey="(row)=>row.id" :data-source="accYpPageList" :columns="accessColumns"
                        :pagination="accYpPagination" :loading="loading">
                        <template slot="number" slot-scope="text, record, index">
                            <a-input type="number" style="width:100px" placeholder="请输入数量"
                                v-model="accYpPageList[index].number" />
                        </template>
                    </a-table>
                </div>
            </template>
        </a-card>

    </div>
</template>
<script lang="ts">
import { Vue, Component, Prop, Watch } from "vue-property-decorator";
import { h } from "vue";
import warningApi from "@/api/warningApi";
import { format, toDecimalNoZero } from "@/utils";
import { InputNumber } from "ant-design-vue";
import nextApi from "@/api/nextApi";

@Component({
    name: "dom",
    components: {},
})
export default class index extends Vue {
    @Prop({ default: false }) visible!: boolean;
    @Prop({ default: "" }) planSimulation!: any;
    @Prop({ default: "" }) formData!: any;
    @Prop({ default: "" }) parentInfo!: any;

    @Watch("planSimulation")
    visibleChange() {
        if (this.planSimulation.length > 0) {
            const planSerial = this.getStorageBatch();
            this.typeArr = this.planSimulation.map((item, idx) => {
                item.planSerial = planSerial + "" + idx;
                return { title: item.planName, val: item.planName };
            });
            this.setPageList();
        }
    }
    planSimulationObj = {
        包装计划: null,
        制剂计划: null,
        提取计划: null,
        饮片计划: null,
    };
    loading = false;
    typeArr = [];
    pageData = {};
    pageType = "包装计划";
    pageParams: any = {
        keywords: "",
        searchStatus: undefined,
    };
    pageList: any[] = [{ id: 1, number: 20 }];

    // 包装计划表格
    packageColumns = [
        {
            align: "center",
            dataIndex: "batch",
            key: "batch",
            title: "颗粒批号",
        },
        {
            align: "center",
            dataIndex: "spec",
            key: "spec",
            title: "包装规格",
        },
        {
            align: "center",
            dataIndex: "surplus",
            key: "surplus",
            title: "颗粒数量",
        },
        {
            align: "center",
            dataIndex: "qualityState",
            key: "qualityState",
            title: "质量状态",
            customRender: (text: string, record: any, index: number) => (record.qualityState === "1" ? "合格" : "待检"),
        },
        {
            align: "center",
            dataIndex: "varietyName7",
            key: "varietyName8",
            title: "包装数量",
            scopedSlots: { customRender: "number" },
        },
    ];
    // 制剂计划表格
    preparColumns = [
        {
            align: "center",
            dataIndex: "batch",
            key: "batch",
            title: "提取物批号",
        },
        {
            align: "center",
            dataIndex: "surplus",
            key: "surplus",
            title: "提取物数量",
        },
        {
            align: "center",
            dataIndex: "qualityState",
            key: "qualityState",
            title: "质量状态",
            customRender: (text: string, record: any, index: number) => (record.qualityState === "1" ? "合格" : "待检"),
        },
        {
            align: "center",
            dataIndex: "varietyName7",
            key: "varietyName8",
            title: "投入数量",
            scopedSlots: { customRender: "number" },
        },
    ];
    // 提取计划表格
    extractColumns = [
        {
            align: "center",
            dataIndex: "batch",
            key: "batch",
            title: "提取饮片批号",
        },
        {
            align: "center",
            dataIndex: "surplus",
            key: "surplus",
            title: "提取饮片数量",
        },
        {
            align: "center",
            dataIndex: "qualityState",
            key: "qualityState",
            title: "质量状态",
            customRender: (text: string, record: any, index: number) => (record.qualityState === "1" ? "合格" : "待检"),
        },
        {
            align: "center",
            dataIndex: "varietyName7",
            key: "varietyName8",
            title: "投入数量",
            scopedSlots: { customRender: "number" },
        },
        {
            align: "center",
            dataIndex: "count",
            key: "count",
            title: "批次数",
            scopedSlots: { customRender: "count" },
        },
    ];
    // 饮片计划表格
    pieceColumns = [
        {
            align: "center",
            dataIndex: "batch",
            key: "batch",
            title: "药材批号",
        },
        {
            align: "center",
            dataIndex: "surplus",
            key: "surplus",
            title: "中药材数量",
        },
        {
            align: "center",
            dataIndex: "qualityState",
            key: "qualityState",
            title: "质量状态",
            customRender: (text: string, record: any, index: number) => (record.qualityState === "1" ? "合格" : "待检"),
        },
        {
            align: "center",
            dataIndex: "varietyName7",
            key: "varietyName8",
            title: "投入数量",
            scopedSlots: { customRender: "number" },
        },
    ];
    // 辅料表格
    accessColumns = [
        {
            align: "center",
            dataIndex: "batch",
            key: "batch",
            title: "辅料批号",
        },
        {
            align: "center",
            dataIndex: "surplus",
            key: "surplus",
            title: "辅料数量",
        },
        {
            align: "center",
            dataIndex: "materialName",
            key: "materialName",
            title: "辅料名称",
        },
        {
            align: "center",
            dataIndex: "varietyName7",
            key: "varietyName8",
            title: "投入数量",
            scopedSlots: { customRender: "number" },
        },
    ];
    tabChange(e: string) {
        this.pageType = e;
    }

    bzPageList = [];
    zjPageList = [];
    tqPageList = [];
    ypPageList = [];
    mounted() {
        if (this.planSimulation.length > 0) {
            const planSerial = this.getStorageBatch();
            this.typeArr = this.planSimulation.map((item, idx) => {
                item.planSerial = planSerial + "" + idx;
                return { title: item.planName, val: item.planName };
            });

            this.setPageList();
        }
        // 获取辅料列表
        this.getYpAccList();
        this.getTqAccList();
        this.getZjAccList();
    }

    accYpPagination = {
        pageSize: 10,
        current: 1,
        total: 0,
        showTotal: (total: number) => `共${total}条`,
        onChange: this.accYpPageChange,
    };
    accTqPagination = {
        pageSize: 10,
        current: 1,
        total: 0,
        showTotal: (total: number) => `共${total}条`,
        onChange: this.accTqPageChange,
    };
    accZjPagination = {
        pageSize: 10,
        current: 1,
        total: 0,
        showTotal: (total: number) => `共${total}条`,
        onChange: this.accZjPageChange,
    };
    accYpPageChange(page: number, pageSize: number) {
        this.accYpPagination.pageSize = pageSize;
        this.accYpPagination.current = page;
        this.getYpAccList();
    }
    accTqPageChange(page: number, pageSize: number) {
        this.accTqPagination.pageSize = pageSize;
        this.accTqPagination.current = page;
        this.getTqAccList();
    }
    accZjPageChange(page: number, pageSize: number) {
        this.accZjPagination.pageSize = pageSize;
        this.accZjPagination.current = page;
        this.getZjAccList();
    }
    accYpPageList = [];
    accTqPageList = [];
    accZjPageList = [];

    async getYpAccList() {
        this.pageList = [];
        try {
            this.loading = true;
            const res = await warningApi.materialStockList({
                pageSize: this.accYpPagination.pageSize,
                page: this.accYpPagination.current,
                materialType: "辅料",
            });
            this.accYpPagination.total = res.data?.total || 0;
            this.accYpPageList = res.data?.records || [];
        } finally {
            this.loading = false;
        }
    }
    async getTqAccList() {
        this.pageList = [];
        try {
            this.loading = true;
            const res = await warningApi.materialStockList({
                pageSize: this.accTqPagination.pageSize,
                page: this.accTqPagination.current,
                materialType: "辅料",
            });
            this.accTqPagination.total = res.data?.total || 0;
            this.accTqPageList = res.data?.records || [];
        } finally {
            this.loading = false;
        }
    }
    async getZjAccList() {
        this.pageList = [];
        try {
            this.loading = true;
            const res = await warningApi.materialStockList({
                pageSize: this.accZjPagination.pageSize,
                page: this.accZjPagination.current,
                materialType: "辅料",
            });
            this.accZjPagination.total = res.data?.total || 0;
            this.accZjPageList = res.data?.records || [];
        } finally {
            this.loading = false;
        }
    }
    setPageList() {
        const data = {
            包装计划: "bzPageList",
            制剂计划: "zjPageList",
            提取计划: "tqPageList",
            饮片计划: "ypPageList",
        };
        this.planSimulation.forEach((item) => {
            const xuqiu = Number(item.xuqiu);
            const inNum = Number(item.inNum);

            let total = 0;
            const list = item.materialStockList.map((materList) => {
                const surplus = Number(materList.surplus);
                let number = "";
                if (total < xuqiu) {
                    number = toDecimalNoZero(total + surplus > xuqiu ? xuqiu - total : surplus);
                    total += surplus;
                } else {
                    number = "";
                }
                return {
                    ...materList,
                    number,
                };
            });

            this.planSimulationObj[item.planName] = JSON.parse(JSON.stringify(item));
            const name = data[item.planName];
            if (name) {
                //this.bzPageList=item.materialStockList
                //this.$set(this,name, item.materialStockList);
                this[name] = list;
            }
        });
    }
    dateChange(e: any[]) {
        this.pageParams.date = e.map((item) => item.format("YYYY-MM-DD"));
    }

    getPageInfo() {
        const data = {
            包装计划: "bzPageList",
            制剂计划: "zjPageList",
            提取计划: "tqPageList",
            饮片计划: "ypPageList",
        };
        const accData = {
            制剂计划: "accZjPageList",
            提取计划: "accTqPageList",
            饮片计划: "accYpPageList",
        };
        let validType = true;
        let errorTips = "";
        const processPlanDetailList: any[] = [];
        for (let i in data) {
            let inputTotal = 0;
            const plan = this.planSimulationObj[i];
            const xuqiu = Number(plan.xuqiu); // 需求量
            const inNum = Number(plan.inNum); // 计划生产量

            const processPlanInputList: any[] = [];

            // 循环投料
            this[data[i]].forEach((item) => {
                const inputNumber = Number(item.number);
                const surplus = Number(item.surplus);

                inputTotal += inputNumber;
                if (inputNumber > surplus) {
                    validType = false;
                    errorTips = `${i},批号：${item.batch},填写数量不能大于库存`;
                }
                if (inputNumber > 0) {
                    processPlanInputList.push({
                        stockId: item.id,
                        batch: item.batch,
                        inputNum: item.number,
                        materialName: item.materialName,
                        materialType: item.materialType,
                        materialId: item.materialId,
                    });
                }
            });

            // 循环辅料
            if (accData[i]) {
                this[accData[i]].forEach((item) => {
                    const inputNumber = Number(item.number);
                    const surplus = Number(item.surplus);
                    if (inputNumber > surplus) {
                        validType = false;
                        errorTips = `${i},批号：${item.batch},填写数量不能大于库存`;
                    }
                    if (inputNumber > 0) {
                        processPlanInputList.push({
                            stockId: item.id,
                            batch: item.batch,
                            inputNum: item.number,
                            materialName: item.materialName,
                            materialType: item.materialType,
                            materialId: item.materialId,
                        });
                    }
                });
            }

            if (inputTotal > xuqiu + 0.01) {
                validType = false;
                errorTips = `${i},填写数量不能大于需求量`;
            }
            if (inputTotal + inNum < xuqiu - 0.01) {
                validType = false;
                errorTips = `${i},填写数量不能小于需求量`;
            }

            if (xuqiu > 0) {
                if (!plan.batch) {
                    validType = false;
                    errorTips = `${i},批号不能为空`;
                }
                if (!plan.finishTime) {
                    validType = false;
                    errorTips = `${i},预计完成时间不能为空`;
                }
            }
            if (!validType) break;
            processPlanDetailList.push({
                planName: plan.planName,
                name: plan.planName,
                batch: plan.batch,
                finishTime: plan.finishTime,
                inputNum: plan.xuqiu,
                inputTotal,
                planSerial: plan.planSerial,
                prodNum: plan.inNum,
                standard: this.parentInfo.standard,
                spec: this.parentInfo.spec,
                processPlanInputList,

                techNotice: plan.techNotice,
                techProcess: plan.techProcess,
            });
        }

        if (!validType) {
            this.$message.error(errorTips);
            return false;
        }
        return processPlanDetailList;
    }
    getStorageBatch() {
        const time = new Date().getTime();
        let randomNumber: number | string = Math.floor(Math.random() * 100);
        // 如果随机数小于10，则在前面添加一个0
        if (randomNumber < 10) {
            randomNumber = "0" + randomNumber;
        }
        return format(time, "MMddhhmm" + randomNumber);
    }
}
</script>
<style lang="scss">
.planList-index {
    .planList-top {
        font-size: 16px;
        padding-bottom: 10px;
    }
    .planList-title {
        font-weight: bold;
        font-size: 20px;
    }

    .overview-panel {
        background-color: #fff;
        padding: 10px 10px;
    }
    .overview-title {
        margin-right: 30px;
    }
    .overview-titlebox {
        padding: 10px 0;
    }
}
</style>
